//
//  services.m
//  alotOf
//
//  Created by Mac_Black_Mini on 2025/9/1.
//

#import "ServicesManager.h"
#import "VPNConfigInfo.h"
#import "LinkOperation.h"
#import "VPNConfigInfo.h"
#import "BuyOperation.h"
#import "WLToastView.h"
#import "AdvertisementOperation.h"
NS_ASSUME_NONNULL_BEGIN

@implementation ServicesManager
#pragma mark - init
static ServicesManager *instance;
+ (instancetype)shared {
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        if(!instance){
            instance = [[super allocWithZone:NULL] init];
            [LinkOperation shared];
        }
    });
    return instance;
}

+ (instancetype)allocWithZone:(struct _NSZone *)zone {
    return [self shared];
}

+ (id)alloc {
    return [self allocWithZone:NULL];
}
+(void)startVPN{
    
    LinkOperation *link =[LinkOperation shared];
  
    [link linkVPNwithConfiginfo];
    link.successBlock = ^(bool sf) {
        NSLog(@"%d",sf);
    };
}

+(void)opAdS{
    LinkOperation *link =[LinkOperation shared];
    VPNConfigInfo *config =[link getConfig];
    
    [AdvertisementOperation showAdWithConfig:config.open_ad];
}


+(void)buy{
    BuyOperation *buy =[BuyOperation sharedInstance];
   
    
    [buy requestProductsWithIds:@[@"$rc_monthly"] completion:^(IAPStatus status, NSDictionary * _Nullable info, NSError * _Nullable error) {
        
        if (status == IAPStatusNoProducts) {
            [WLToastView showToast:@"没有获取到产品"];
        }
        
        
    }];
    
}

@end

NS_ASSUME_NONNULL_END
